#ifndef _SYSTEM_H
#define _SYSTEM_H

#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>

#define __I     volatile const
#define __O     volatile
#define __IO    volatile

typedef  uint8_t    u8;
typedef  uint16_t   u16;
typedef  uint32_t   u32;
typedef  uint64_t   u64;

#define write64(addr, data)         *(volatile uint64_t *)(addr) = (data)
#define write32(addr, data)         *(volatile uint32_t *)(addr) = (data)
#define write16(addr, data)         *(volatile uint16_t *)(addr) = (data)
#define write8( addr, data)         *(volatile uint8_t *)(addr)  = (data)

#define read64(addr)                (*(volatile uint64_t *)(addr))
#define read32(addr)                (*(volatile uint32_t *)(addr))
#define read16(addr)                (*(volatile uint16_t *)(addr))
#define read8(addr)                 (*(volatile uint8_t *)(addr))

#define debug_info(data)            *(volatile uint32_t *)(0x01fffff4) = (uint32_t)(data)
#define debug_error(data)           *(volatile uint32_t *)(0x01fffff8) = (uint32_t)(data)
#define debug_pass()                *(volatile uint32_t *)(0x01fffffc) = (uint32_t)(0x7E57E00D)
#define debug_fail()                *(volatile uint32_t *)(0x01fffffc) = (uint32_t)(0x7E57FA10)
#define debug_char(data)            *(volatile uint32_t *)(0x01fffff0) = (uint32_t)(data)

typedef enum {RESET = 0, SET = !RESET} FlagStatus, ITStatus;

typedef enum { DISABLE=0, ENABLE=!DISABLE} FuncState;

#endif

